//
//  ViewControllerImpl.swift
//  EagleFastSwift
//
//  Created by ggx on 2017/7/18.
//  Copyright © 2017年 高广校. All rights reserved.
//  

import UIKit
import RxSwift
import SnapKit
import UIKit
//import RxCocoa
class ViewControllerImpl: UIViewController {
    
    //    override var hidesBottomBarWhenPushed: Bool
    @objc var Id : String = ""
    var dataArray: [Any] = []
    var disposeBag = DisposeBag()
    var dataStructArray : NSMutableArray = []
    var customTitle: String = "" {
        didSet {
            self.navigationItem.title = customTitle
        }
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
//        self.navigationController?.navigationBar.naviBarStyle(barStyle: .blackTranslucent)
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
//        self.navigationController?.navigationBar.updateOffX()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
//        setEdgesLayout(layoutValue: 0)
        self.edgesForExtendedLayout = .all
        
        if self.navigationController != nil {
            if (self.navigationController?.viewControllers.count)! > 1 {
                //修改返回键
                let btn = UIButton(type: .custom)
                btn.frame = CGRect(x: 0, y: 0, width: 100, height: 44)
                let i = UIImageView(image: UIImage(named: "back"))
                btn.addSubview(i)
                btn.addTarget(self, action: #selector(GoBack), for: .touchUpInside)
                i.contentMode = .scaleAspectFit;
                i.frame = CGRect(x: 0, y: 12, width: 20, height: 20)
            
                self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btn)
                self.navigationItem.leftBarButtonItem?.tintColor = .black
            }
        }
        
    }

    
//    lazy var navBar: BSNavBar = {
//        let view = BSNavBar()
//        view.backgroundColor = KNavBackgroundColor
//        view.setNavigationBar(title: customTitle, popVC: {[weak self] in
//            self?.GoBack()
//        })
//        return view
//    }()
    
    @objc func GoBack()  {
//        self.p()
    }
    
    @objc func setLineViewHidden(isHidden:Bool) {
        if let nav = navigationController?.navigationBar {
            let img =  slnFindHairlineImageViewUnder(view: nav)
            img.isHidden = isHidden
        }
    }
    
    func slnFindHairlineImageViewUnder(view:UIView) -> UIImageView {
        //遍历下面黑线，并隐藏
//        UIImageView.any
        if view.isKind(of: UIImageView.self), view.height <= 1.0 {
            return view as! UIImageView;
        }

        for subView in view.subviews {
            let img = slnFindHairlineImageViewUnder(view: subView)
                return img;
        }
        return UIImageView();
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
